package com.mindskip.xzs.repository;

import com.mindskip.xzs.domain.TaskExam;
import com.mindskip.xzs.repository.base.MyMapper;
import com.mindskip.xzs.viewmodel.admin.task.TaskPageRequestVM;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TaskExamMapper extends MyMapper<TaskExam> {
//    int deleteByPrimaryKey(Integer id);
//
//    int insert(TaskExam record);
//
//    int insertSelective(TaskExam record);
//
//    TaskExam selectByPrimaryKey(Integer id);
//
//    int updateByPrimaryKeySelective(TaskExam record);
//
//    int updateByPrimaryKey(TaskExam record);

    String queryParams = " id, title, grade_level gradeLevel, frame_text_content_id frameTextContentId, create_user createUser, create_time createTime, deleted, create_user_name createUserName ";


    @Select("<script>" +
            "select" + queryParams +
            "from t_task_exam " +
            "where deleted=0 " +
            "<if test=\"gradeLevel != null\">\n" +
            " and grade_level = #{gradeLevel}\n" +
            "</if>" +
            "</script>")
    List<TaskExam> page(TaskPageRequestVM requestVM);

    @Select("select " + queryParams +
            "from t_task_exam\n" +
            "where deleted=0\n" +
            "and grade_level = #{gradeLevel}")
    List<TaskExam> getByGradeLevel(@Param("gradeLevel") Integer gradeLevel);

}
